package com.freewater.springboot.demo.aop.example;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration
@EnableAspectJAutoProxy
public class AppConfig {

    @Bean
    public SomeBusinessService someBusinessService() {
        return new SomeBusinessService();
    }

    @Bean
    public ConcurrentOperationExecutor concurrentOperationExecutor() {
        ConcurrentOperationExecutor concurrentOperationExecutor = new ConcurrentOperationExecutor();
        concurrentOperationExecutor.setMaxRetries(3);// 最多重试3次
        // Note that the aspect implements the Ordered interface so that we can
        // set the precedence of the aspect higher than the transaction
        // advice (we want a fresh transaction each time we retry).
        concurrentOperationExecutor.setOrder(100);
        return concurrentOperationExecutor;
    }
}
